package com.matt.components.intercepter;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * *******************************
 * Created by Ron.
 * form com.matt
 * on 2017/5/18
 * *******************************
 */
@Configuration
public class WebInterceptor extends WebMvcConfigurerAdapter {

    @Bean
    ActionLogInterceptor actionLogInterceptor() {
        return new ActionLogInterceptor();
    }

    @Bean
    AuthInterceptor authInterceptor(){return new AuthInterceptor();}

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(actionLogInterceptor())
                .addPathPatterns("/**");

        registry.addInterceptor(authInterceptor())
                .addPathPatterns("/**")
                .excludePathPatterns("/scheduler/**", "/other_system/**")
                .excludePathPatterns("/api/web/leads/getAllArea", "/other_system/**")
                .excludePathPatterns("/swagger-resources/**", "/webjars/**", "/swagger-ui.html/**");
    }
}